<template>
    <div class="tab">
        <div class="tab-item avator">
            <el-image :src="userInfo.avatar" fit="cover">
                <div slot="placeholder" class="image-slot">
                    加载中<span class="dot">...</span>
                </div>
                <div slot="error" class="image-slot">
                    <i class="el-icon-picture-outline"></i>
                </div>
            </el-image>
        </div>
        <div class="tab-item msg" @click="onTabChange($event,'msg')">
            <i class="el-icon-s-comment icon icon-select"/>
        </div>
        <div class="tab-item address-book" @click="onTabChange($event,'tongxulu')">
            <i class="iconfont icon-tongxunlu icon"/>
        </div>
        <div class="tab-item group" @click="onTabChange($event,'group')">
            <i class="iconfont icon-qunzu icon"/>
        </div>
        <!-- 底部图标 -->
        <div class="bottom">
            <div class="tab-item user">
                <i class="iconfont icon-yonghu icon"/>
            </div>
            <div class="tab-item more">
                <i class="iconfont icon-liebiao icon"/>
            </div>
            <div class="tab-item exit">
                <i class="iconfont icon-tuichu icon"/>
            </div>
        </div>
    </div>
</template>
<script lang="ts">
import {Vue,Component,Emit,Prop} from 'vue-property-decorator'

@Component
export default class SliderTab extends Vue {

    $store: any


    // tab发生变化
    @Emit()
    public onTabChange(e:Event,msg:string){
        document.querySelectorAll('.tab-item .icon').forEach(el=>{
            (el as HTMLElement).classList.remove('icon-select')
        });
        const targetEl = e.target as HTMLLIElement;
        if(targetEl.localName == 'i'){
            targetEl.classList.add('icon-select')
        }else{
            targetEl.querySelector('.icon')?.classList.add('icon-select')
        }
        return msg
    }

     // 用户信息
    get userInfo(){
        return this.$store.state.user;
    }
    
}
</script>
<style lang="less" scoped>
@import '../css/index.less';
@import '../css/iconfont.less';
.tab{
    min-width: 60px;
    height: 100%;
    background-color: @theme-color;
    padding: 10px 5px;
    overflow: hidden;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-direction: column;
    
    div.tab-item{
        width: 40px;
        height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        .icon{
            color:white;
            font-size: 25px;
            cursor: pointer;
            &:hover{
                color: aqua;
            }
        }
        .icon-select{
            color: #333399;
        }
    }
    .avator{
        margin-bottom: 20px;
        border-radius: 4px;
        overflow: hidden;
        .el-image{
            width: 100%;
            height: 100%;
        }
    }
    .bottom{
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: center;
    }
}
</style>